/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
	vector<int> vec;
	void traversal(TreeNode* root)
	{
		if (root == nullptr)  return;
		traversal(root->left);
		vec.push_back(root->val);
		traversal(root->right);
	}
	int getMinimumDifference(TreeNode* root) {
		vec.clear();
		traversal(root);
		//sort(vec.begin(), vec.end());
		int Min_path = INT_MAX;
		for (int i = 1; i < vec.size(); i++)
		{
			if (abs(vec[i] - vec[i - 1]) < Min_path)
			{
				Min_path = abs(vec[i] - vec[i - 1]);
			}
		}
		return Min_path;
	}
};